unit frmNamePicker;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
  StdCtrls, Buttons, MMSystem;

type

  { TfrmNameSelection }

  TfrmNameSelection = class(TForm)
    btnPick: TBitBtn;
    btnAdd: TButton;
    lblClass: TLabel;
    lbNames: TListBox;
    procedure btnLoadClick(Sender: TObject);
    procedure btnPickClick(Sender: TObject);
    procedure btnAddClick(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
    Group       : String;
  end;


implementation

{ TfrmNameSelection }
uses
DataModule;

procedure TfrmNameSelection.btnAddClick(Sender: TObject);
begin
    lbNames.Items.Add(InputBox('Lesson Tools', 'Please enter a name', ''));
end;

procedure TfrmNameSelection.btnLoadClick(Sender: TObject);
var
   i : Integer;
begin
    for i := 0 to DataModule1.FirstNames.Count-1 do
        lbNames.Items.Add(DataModule1.FirstNames.Strings[i]);
end;

procedure TfrmNameSelection.btnPickClick(Sender: TObject);
var
   i,NoNames, selected:Integer;
begin
   Randomize;
   NoNames := lbNames.Items.Count;
   for i := 0 to (NoNames) do
   begin
        selected := Random(NoNames) + 1;
        lbNames.Selected[selected] := True;
        sleep(100);
   end;
          PlaySound('alarm_3.wav',0,0);

end;

initialization
  {$I frmnamepicker.lrs}

end.

